package outil;

public class SiChaine implements Action {

    private Predicat[] pTPredicat;
    private Action[] pTAction;

    public final static Action instance(Predicat[] pTPredicat, Action[] pTAction) {
        return new SiChaine(pTPredicat, pTAction);
    }

    public SiChaine(Predicat[] pTPredicat, Action[] pTAction) {
        this.pTPredicat = pTPredicat;
        this.pTAction = pTAction;
    }

    public void exec() {
        for (int p = 0; p < pTPredicat.length; p++) {
            if (pTPredicat[p].eval()) {
                pTAction[p].exec();
            }
        }
    }
}
